home *** CD-ROM | disk | FTP | other *** search
Java Source | 2000-09-28 | 4.0 KB | 164 lines | [TEXT/SNJ2] |
- import java.awt.*;
- import java.awt.event.KeyEvent;
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.io.IOException;
- import java.net.URL;
-
- public class AboutCCDialog extends Dialog
- {
- public AboutCCDialog(Frame parent)
- {
- super(parent, true);
-
- // This code is automatically generated by Visual Cafe when you add
- // components to the visual environment. It instantiates and initializes
- // the components. To modify the code, only use code syntax that matches
- // what Visual Cafe can generate, or Visual Cafe may be unable to back
- // parse your Java file into its visual environment.
- //{{INIT_CONTROLS
- GridBagLayout gridBagLayout;
- gridBagLayout = new GridBagLayout();
- setLayout(gridBagLayout);
- setVisible(false);
- setSize(440,260);
- setBackground(new Color(-1644826));
-
- defaultBorder1 = new DefaultBorder();
- defaultBorder1.setBounds(178,227,64,26);
- GridBagConstraints gbc;
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 1;
- gbc.fill = GridBagConstraints.NONE;
- gbc.insets = new Insets(0,0,10,0);
- ((GridBagLayout)getLayout()).setConstraints(defaultBorder1, gbc);
- okButton = new java.awt.Button();
- okButton.setLabel("OK");
- okButton.setBounds(3,3,58,20);
- defaultBorder1.add(okButton);
- add(defaultBorder1);
- textArea1 = new java.awt.TextArea("",0,0,TextArea.SCROLLBARS_VERTICAL_ONLY);
- textArea1.setEditable(false);
- textArea1.setText("");
- textArea1.setFont(new Font("SansSerif", Font.PLAIN, 9));
- textArea1.setBackground(new Color(16777215));
- gbc = new GridBagConstraints();
- gbc.gridx = 0;
- gbc.gridy = 0;
- gbc.weightx = 0.5;
- gbc.weighty = 0.5;
- gbc.fill = GridBagConstraints.BOTH;
- gbc.insets = new Insets(10,10,10,10);
- ((GridBagLayout)getLayout()).setConstraints(textArea1, gbc);
- add(textArea1);
- setTitle("About...");
- setResizable(false);
- //}}
-
- //{{REGISTER_LISTENERS
- SymWindow aSymWindow = new SymWindow();
- this.addWindowListener(aSymWindow);
- SymAction lSymAction = new SymAction();
- okButton.addActionListener(lSymAction);
- SymKey aSymKey = new SymKey();
- textArea1.addKeyListener(aSymKey);
- okButton.addKeyListener(aSymKey);
- this.addKeyListener(aSymKey);
- //}}
-
- try
- {
- String contents = Util.readTextResourceFile("files/About.txt", this);
- textArea1.setText(contents);
- }
- catch (FileNotFoundException exc)
- {
- System.err.println(exc);
- }
- catch (IOException exc)
- {
- System.err.println(exc);
- }
- }
-
- /**
- * Shows or hides the component depending on the boolean flag b.
- * @paramLabel b if true, show the component; otherwise, hide the component.
- * @see java.awt.Component#isVisible
- */
- public void setVisible(boolean b)
- {
- if(b)
- {
- Dimension sSize = Toolkit.getDefaultToolkit().getScreenSize();
- Dimension dSize = getSize();
-
- setLocation((sSize.width - dSize.width) >> 1, (int)(0.33333333 * sSize.height));
- }
- super.setVisible(b);
- }
-
- public void update(Graphics g)
- {
- paint(g);
- }
-
- public void close()
- {
- // Hide the Dialog
- setVisible(false);
- dispose();
- }
-
- //{{DECLARE_CONTROLS
- java.awt.Button okButton;
- java.awt.TextArea textArea1;
- DefaultBorder defaultBorder1;
- //}}
-
- class SymWindow extends java.awt.event.WindowAdapter
- {
- public void windowClosing(java.awt.event.WindowEvent event)
- {
- Object object = event.getSource();
- if (object == AboutCCDialog.this)
- AboutCCDialog_WindowClosing(event);
- }
- }
-
- void AboutCCDialog_WindowClosing(java.awt.event.WindowEvent event)
- {
- close();
- }
-
- class SymAction implements java.awt.event.ActionListener
- {
- public void actionPerformed(java.awt.event.ActionEvent event)
- {
- Object object = event.getSource();
- if (object == okButton)
- okButton_ActionPerformed(event);
- }
- }
-
- void okButton_ActionPerformed(java.awt.event.ActionEvent event)
- {
- close();
- }
-
- class SymKey extends java.awt.event.KeyAdapter
- {
- public void keyPressed(java.awt.event.KeyEvent event)
- {
- handleKeyPressed(event);
- }
- }
-
- void handleKeyPressed(java.awt.event.KeyEvent event)
- {
- if (event.getKeyCode() == KeyEvent.VK_ENTER)
- close();
- }
- }
-